<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>日志管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
	$(document).ready(function() {
		layui.use(['laypage', 'form'], function(){
		  var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
		  form.render();
		  var laypage = layui.laypage;
		  laypage.render({
			  elem: 'pageDiv',
			  count: ${page.count} //数据总数，从服务端得到
			  ,curr:${page.pageNo}
			  ,limit:30
			  ,layout: ['prev', 'page', 'next', 'count']
			  ,jump: function(obj, first){
			    //obj包含了当前分页的所有参数，比如：
			   // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
			   // console.log(obj.limit); //得到每页显示的条数
			    
			    //首次不执行
			    if(!first){
			    	$("#firstPage").val(false);
			    	page(obj.curr,obj.limit);
			    }
			  }
			});
		  	var table = layui.table;
			table.init('logTable',{limit:30});
		}); 
	}); 
	
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
	    	return false;
	    }
	</script>
</head>
<body style="padding: 10px;">
<!-- 	<ul class="nav nav-tabs"> -->
<%-- 		<li class="active"><a href="${ctx}/sys/log/">日志列表</a></li> --%>
<!-- 	</ul> -->
<div class="layui-tab-content"></div>
<blockquote class="layui-elem-quote quoteBox">
	<form:form id="searchForm" action="${ctx}/sys/log/" method="post" class="layui-form">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
			<div>
	       		<div class="layui-inline">
					<label class="layui-form-label">操作菜单：</label>
						<div class="layui-input-inline">
							<input id="title" name="title" type="text" maxlength="50" class="layui-input" value="${log.title}"/>
						</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">用户ID：</label>
						<div class="layui-input-inline">
							<input id="createBy.id" name="createBy.id" type="text" maxlength="50" class="layui-input" value="${log.createBy.id}"/>
						</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">URI：</label>
					<div class="layui-input-inline">
						<input id="requestUri" name="requestUri" type="text" maxlength="50" class="layui-input" value="${log.requestUri}"/>
					</div>
				</div>
				<br/>
				<div  class="layui-inline">
					<label class="layui-form-label">日期范围：&nbsp;</label>
						<input id="beginDate" name="beginDate" type="text" readonly="readonly" maxlength="20" class="layui-input Wdate" style="width:163px;"
							value="<fmt:formatDate value="${log.beginDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
				</div>
				--
				<div class="layui-inline">
						<input id="endDate" name="endDate" type="text" readonly="readonly" maxlength="20" class="layui-input Wdate" style="width:163px;"
						value="<fmt:formatDate value="${log.endDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
				</div>
				
				<div class="layui-input-inline">
					<label class="layui-form-label" for="exception"></label>
					 <input id="exception" name="exception"  lay-skin="primary" type="checkbox"${log.exception eq '1'?' checked':''} value="1"/>只查询异常信息
				</div>
				<div>
					<input id="btnSubmit" class="layui-btn search_btn" type="submit" value="查询"/>&nbsp;&nbsp;
				</div>
			</div>
	</form:form>
	</blockquote>
	<sys:message content="${message}"/>
	<table id="contentTable" class="layui-table" lay-filter="logTable">
		<thead><tr>
			<th lay-data="{field:'menu', minWidth:100}">操作菜单</th>
			<th lay-data="{field:'user', minWidth:100}">操作用户</th>
			<th lay-data="{field:'compny', minWidth:100}">所在公司</th>
			<th lay-data="{field:'part', minWidth:100}">所在部门</th>
			<th lay-data="{field:'uri', minWidth:90}">URI</th>
			<th lay-data="{field:'upWay', minWidth:90}">提交方式</th>
			<th lay-data="{field:'ip', minWidth:150}">操作者IP</th>
			<th lay-data="{field:'time', minWidth:130}">操作时间</th>
		</thead>
		<tbody><%request.setAttribute("strEnter", "\n");request.setAttribute("strTab", "\t");%>
		<c:forEach items="${page.list}" var="log">
			<tr>
				<td>${log.title}</td>
				<td>${log.createBy.name}</td>
				<td>${log.createBy.company.name}</td>
				<td>${log.createBy.office.name}</td>
				<td><strong>${log.requestUri}</strong></td>
				<td>${log.method}</td>
				<td>${log.remoteAddr}</td>
				<td><fmt:formatDate value="${log.createDate}" type="both"/></td>
			</tr>
			<c:if test="${not empty log.exception}"><tr>
				<td colspan="8" style="word-wrap:break-word;word-break:break-all;">
<%-- 					用户代理: ${log.userAgent}<br/> --%>
<%-- 					提交参数: ${fns:escapeHtml(log.params)} <br/> --%>
					异常信息: <br/>
					${fn:replace(fn:replace(fns:escapeHtml(log.exception), strEnter, '<br/>'), strTab, '&nbsp; &nbsp; ')}</td>
			</tr></c:if>
		</c:forEach>
		</tbody>
	</table>
<%-- 	<div class="pagination">${page}</div> --%>
	<div id="pageDiv" class="pagination layui-elem-field layui-field-title">${page}</div>

</body>
</html>